package base_grammar

import (
	"fmt"
)

func map_f3() {
	var m1 = map[string]string{
		"name": "zhoujl",
		"age":  "28",
		"email": `
			dasdwaewqeqwe"
			weqweweqjjjjjj
		`,
	}

	/* for k := range m1 {
		fmt.Printf("k: %v\n", k)
	} */

	for key, value := range m1 {
		fmt.Printf("%v : %v\n", key, value)
	}
}

func map_f2() {
	var m1 = map[string]string{
		"name": "zhoujl",
		"age":  "28",
		"eamial": `
			dasdwaewqeqwe"
			weqweweqjjjjjj
		`,
	}
	fmt.Printf("m1: %v\n", m1)

	m2 := make(map[string]string)
	m2["name"] = "zhoujl"
	fmt.Printf("m2: %v\n", m2)

	fmt.Printf("m1[\"age\"]: %v\n", m1["age"])

	// 返回  值+key是否存在
	v, exist := m2["name"]
	fmt.Printf("v: %v\n", v)
	fmt.Printf("exist: %v\n", exist)

	v, exist = m2["age"]
	fmt.Printf("v: %v\n", v)
	fmt.Printf("exist: %v\n", exist)
}

func map_f1() {
	// map变量的声明
	var m1 map[string]string
	m1 = make(map[string]string)
	fmt.Printf("m1: %v\n", m1)
	fmt.Printf("m1: %T\n", m1)
}
